//“大家都在说”数据
var allSayList = [
    {	
		// 背景
        bg: "../img/community/everybody%20said_img.png",
		// 标题
        title: "#话题：摄影书籍",
        text: "分享那些学摄影的书籍",
		// 标签
        labelList: [
            {
                img: "../img/community/everybody%20said_photo_head%20portrait.png",
                label: "摄影构图学"
            },
            {
                img: "../img/community/everybody%20said_photo_head%20portrait.png",
                label: "摄影构图学"
            },
            {
                img: "../img/community/everybody%20said_photo_head%20portrait.png",
                label: "摄影构图学"
            },
        ]
    },
    {
        bg: "../img/community/everybody%20said_img.png",
        title: "#话题：摄影书籍",
        text: "分享那些学摄影的书籍",
        labelList: [
            {
                img: "../img/community/everybody%20said_photo_head%20portrait.png",
                label: "摄影构图学"
            },
            {
                img: "../img/community/everybody%20said_photo_head%20portrait.png",
                label: "摄影构图学"
            },
            {
                img: "../img/community/everybody%20said_photo_head%20portrait.png",
                label: "摄影构图学"
            },
        ]
    },
]
//左侧“动态”数据
var dynamicLeftList = [
    {
        img: "../img/community/popular%20trends_img1.png",
        count: 6,
        text: "近似色配色让人感觉画面和谐，再添加点缀的互补色就更加完...",
        headImg: "../img/community/everybody%20said_photo_head%20portrait.png",
        name: "小熊先生",
		// 点赞数
        likeCount: 964,
		//是否点赞
        hasLike: true
    },
    {
        img: "../img/community/popular%20trends_img3.png",
        count: 6,
        text: "近似色配色让人感觉画面和谐，再添加点缀的互补色就更加完...",
        headImg: "../img/community/everybody%20said_photo_head%20portrait.png",
        name: "小熊先生",
        likeCount: 964,
        hasLike: false
    },
]
//右侧“动态”数据
var dynamicRightList = [
    {
        img: "../img/community/popular%20trends_img2.png",
        count: 6,
        text: "他推荐的摄影师都是宝藏啊，拍摄的图片都好...",
        headImg: "../img/community/everybody%20said_photo_head%20portrait.png",
        name: "小熊先生",
        likeCount: 964,
        hasLike: false
    },
    {
        img: "../img/community/popular%20trends_img1.png",
        count: 6,
        text: "近似色配色让人感觉画面和谐，再添加点缀的互补色就更加完...",
        headImg: "../img/community/everybody%20said_photo_head%20portrait.png",
        name: "小熊先生",
        likeCount: 964,
        hasLike: true
    },
]
//“大家都在说”
function getAllSay() {
    for (var i = 0; i < allSayList.length; i++) {
        $(".allSayUl").append('<li class="allSayLi"><img src=' + allSayList[i].bg + ' class="bg" /><div class="infoBox"><p class="title">' + allSayList[i].title + '</p><p class="text">' + allSayList[i].text + '</p></div><ul class="labelUl"></ul></li>')
        for (var j = 0; j < allSayList[i].labelList.length; j++) {
            $('.allSayLi:eq(' + i + ')>.labelUl').append('<li class="labelLi"><img class="labelImg" src=' + allSayList[i].labelList[j].img + ' /><div class="label">' + allSayList[i].labelList[j].label + '</div></li>')
        }
    }

}
//动态
function getLeftDyNamic(){
    for (var i = 0; i < dynamicLeftList.length; i++) {
        $(".leftUl").append('<li><div class="imgBox"><img src=' + dynamicLeftList[i].img +
            ' class="img" /><div class="iconBox"><div class="icon"></div><div class="count">' + dynamicLeftList[i].count +
            '</div></div></div><div class="text">' + dynamicLeftList[i].text + '</div><div class="infoBox"><div class="info"><img src='
            + dynamicLeftList[i].headImg + ' class="headImg" /><div class="name">' + dynamicLeftList[i].name + '</div></div><div class="likeBox"><div class="likeIcon"></div><div class="likeCount">' + dynamicLeftList[i].likeCount + '</div></div></div></li>')
        if (dynamicLeftList[i].hasLike) {
            $(".leftUl li:eq(" + i + ") .likeIcon").addClass("hasLike")
        } else {
            $(".leftUl li:eq(" + i + ") .likeIcon").addClass("notLike")
        }
    }
    $(".leftUl .likeIcon").each(function(index){
        $(this).on("click",function(){
            dynamicLeftList[index].hasLike=!dynamicLeftList[index].hasLike
            if(dynamicLeftList[index].hasLike){
                dynamicLeftList[index].likeCount++
            }else{
                dynamicLeftList[index].likeCount--
            }
            $(".leftUl").empty()
            getLeftDyNamic()
        })
        
    })
}
function getRightDyNamic() {
    for (var j = 0; j < dynamicRightList.length; j++) {
        $(".rightUl").append('<li><div class="imgBox"><img src=' + dynamicRightList[j].img +
            ' class="img" /><div class="iconBox"><div class="icon"></div><div class="count">' + dynamicRightList[j].count +
            '</div></div></div><div class="text">' + dynamicRightList[j].text + '</div><div class="infoBox"><div class="info"><img src='
            + dynamicRightList[j].headImg + ' class="headImg" /><div class="name">' + dynamicRightList[j].name + '</div></div><div class="likeBox"><div class="likeIcon"></div><div class="likeCount">' + dynamicRightList[j].likeCount + '</div></div></div></li>')
        if (dynamicRightList[j].hasLike) {
            $(".rightUl li:eq(" + j + ") .likeIcon").addClass("hasLike")
        } else {
            $(".rightUl li:eq(" + j + ") .likeIcon").addClass("notLike")
        }
    }
    $(".rightUl .likeIcon").each(function(index){
        $(this).on("click",function(){
            dynamicRightList[index].hasLike=!dynamicRightList[index].hasLike
            if(dynamicRightList[index].hasLike){
                dynamicRightList[index].likeCount++
            }else{
                dynamicRightList[index].likeCount--
            }
            $(".rightUl").empty()
            getRightDyNamic()
        })
        
    })
}
//
var all = {
    getAllSay,
    getLeftDyNamic,
    getRightDyNamic
}
all.getAllSay()
all.getLeftDyNamic()
all.getRightDyNamic()